home *** CD-ROM | disk | FTP | other *** search
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="text"/>
-
- <xsl:template match="/">
- <xsl:call-template name="pow">
- <xsl:with-param name="base" select="/power/base"/>
- <xsl:with-param name="pow" select="/power/pow"/>
- </xsl:call-template>
- </xsl:template>
-
- <xsl:template name="pow">
- <xsl:param name="base" select="1"/>
- <xsl:param name="pow" select="0"/>
- <xsl:param name="tmpResult" select="1"/>
-
- <xsl:variable name="result">
- <xsl:choose>
- <xsl:when test="$pow >= 0">
- <xsl:value-of select="$tmpResult * $base"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$tmpResult div $base"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="incr">
- <xsl:choose>
- <xsl:when test="$pow >= 0">
- <xsl:value-of select="- 1"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="1"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
-
- <xsl:choose>
- <xsl:when test="$pow = 0">
- <xsl:value-of select="$tmpResult"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="pow">
- <xsl:with-param name="base" select="$base"/>
- <xsl:with-param name="pow" select="$pow + $incr"/>
- <xsl:with-param name="tmpResult" select="$result"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
-
-
-
-